<?php 

require 'facebook-php-sdk/src/facebook.php';

// create application instance
$facebook = new Facebook(array(
'appId' => '107856579288360',
'secret' => '1111111111111111111111',
'cookie' => true,
));

$session = $facebook->getSession();

if (!empty($session))
{
    try{
        $uid = $facebook->getUser();
        $user = $facebook->api('/me');
    }catch (Exception $e){}

    if (!empty($user))
    {   
        //if($_GET['installed'] == '1')
        //{
            //header("Location: http://apps.facebook.com/markomeara_firstapp");
        //}
       // header("Location: http://apps.facebook.com/markomeara_firstapp/");
        echo "Hello".$user['first_name'];
        echo "Session: ".$session;
    }
    else
        die("Error occurred");

}
else{
    $url = $facebook->getLoginUrl();
    echo "<a href = '".$url."'>Click here to add this application.</a>";
}
?>

